package org.mspring.platform.api.rss.elements;

import java.util.ArrayList;
import java.util.List;

import electric.xml.Element;
import electric.xml.Elements;

/**
 * 
 * @author Gao Youbo
 * @since 2013年7月26日
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public class Item extends CategorizedElement {
    private static final long serialVersionUID = -6695803444267246418L;

    public static List getItems(Element paramElement) {
        ArrayList localArrayList = null;
        DublinCore.init(paramElement);
        Elements localElements = paramElement.getElements("item");
        Element localElement;
        if (localElements.size() == 0) {
            localElement = paramElement.getElement("channel");
            localElements = localElement.getElements("item");
        }
        if (localElements.size() > 0) {
            localArrayList = new ArrayList();
            while (localElements.hasMoreElements()) {
                localElement = localElements.next();
                Item localItem = new Item();
                localArrayList.add(localItem);
                localItem.setAbout(DublinCore.getNSAttrValue(localElement, DublinCore.rdf, "about"));
                localItem.setTitle(DublinCore.getElementValue(localElement, "title"));
                localItem.setLink(DublinCore.getElementValue(localElement, "link"));
                localItem.setDescription(DublinCore.getElementValue(localElement, "description"));
                CategorizedElement.setCategories(localElement, localItem);
                DublinCore.setDublinCoreElements(localElement, localItem);
            }
        }
        return localArrayList;
    }

    public boolean equals(Object paramObject) {
        if ((paramObject != null) && (paramObject.getClass() == getClass())) {
            Item localItem = (Item) paramObject;
            String str = localItem.getLink();
            if ((str != null) && (str.equals(getLink()))) {
                return true;
            }
        }
        return false;
    }
}